package com.library.service.impl;/*
 *@author lzg
 *@data 2020/11/29
 */

import com.library.entity.Admin;
import com.library.entity.BorrowRecode;
import com.library.repository.AdminRepository;
import com.library.repository.impl.AdminRepositoryImpl;
import com.library.service.AdminServer;

import java.util.List;

public class AdminServerImpl implements AdminServer {
    AdminRepository adminRepository = new AdminRepositoryImpl();
    @Override
    public Admin login(String username, String password) {
        return adminRepository.login(username, password);
    }

    @Override
    public List<BorrowRecode> findAllApproval(Integer pageIndex, Integer limitNu) {
        return adminRepository.findAllApproval(pageIndex, limitNu);
    }

    @Override
    public int getPageSize(Integer limitNum) {
        int books = adminRepository.getBooks();
        int pageSize = 0;
        if (books%limitNum==0){
            pageSize = books/limitNum;
        }else {
            pageSize = (books/limitNum)+1;
        }
        return pageSize;
    }

    @Override
    public void UpdateBorrowApproval(Integer bookId, Integer sate) {
        //修改审批数据
        adminRepository.UpdateBorrowApproval(bookId, sate);
    }
}
